<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="客户名称" prop="customerName">
        <el-input
          v-model="queryParams.customerName"
          placeholder="请输入客户名称"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!-- <el-form-item label="手机" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入手机"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电话" prop="telephone">
        <el-input
          v-model="queryParams.telephone"
          placeholder="请输入电话"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="邮箱" prop="email">
        <el-input
          v-model="queryParams.email"
          placeholder="请输入邮箱"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
       <el-form-item label="客户类型" prop="customerType">
        <el-select v-model="queryParams.customerType" placeholder="请选择客户类型" clearable size="small">
           <el-option
                v-for="dict in customerTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      <el-form-item label="行业类型" prop="industryType">
        <el-select v-model="queryParams.industryType" placeholder="请选择行业类型" clearable size="small">
           <el-option
                v-for="dict in customerIndustryTypeOptions"
                :key="dict.dictLabel"
                :label="dict.dictLabel"
                :value="dict.dictLabel"
              />
        </el-select>
      </el-form-item>
      <el-form-item label="客户状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择客户状态" clearable size="small">
           <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
       <el-form-item label="是否认领" prop="isReceive">
        <el-select v-model="queryParams.isReceive" placeholder="请选择是否认领" clearable size="small">
           <el-option
                v-for="dict in receiveOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
       
      
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          plain
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['crm:customer:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['crm:customer:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['crm:customer:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          type="info" icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          v-hasPermi="['crm:customer:fullImport']"
        >导入</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          plain
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['crm:customer:export']"
        >导出</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="customerList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"  />
       <el-table-column label="客户编号" width="180" align="center" prop="customerCode" :show-overflow-tooltip="true">
      </el-table-column>
      <el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true">
         <template slot-scope="scope">
           <el-link @click="openCustomer(scope.row)" :underline="false" type="primary" >{{scope.row.customerName}}</el-link>
        </template>
      </el-table-column>
      <el-table-column label="所属部门" align="center" prop="deptName" />
      <el-table-column label="行业类型" align="center" prop="industryType"  show-overflow-tooltip />
      <el-table-column label="客户类型" align="center" prop="customerType"  width="100px">
        <template slot-scope="scope">
              <el-tag prop="customerType" v-for="(item, index) in customerTypeOptions"    v-if="scope.row.customerType==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
      <el-table-column label="总部客户?" align="center" prop="isGeneral"  show-overflow-tooltip />
      <!-- <el-table-column label="手机" align="center" prop="mobile" />
      <el-table-column label="电话" align="center" prop="telephone" />
      <el-table-column label="网址" align="center" prop="website" />
      <el-table-column label="邮箱" align="center" prop="email" /> -->
      <el-table-column label="详细地址" align="center" prop="detailAddress"  show-overflow-tooltip />
      <el-table-column label="客户状态" align="center" prop="status" >
        <template slot-scope="scope">
              <el-tag prop="status" v-for="(item, index) in statusOptions"  :type="scope.row.status==1?'success':'danger'"  v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
      <el-table-column label="是否认领" align="center" prop="isReceive" >
        <template slot-scope="scope">
              <el-tag prop="status" v-for="(item, index) in receiveOptions"  :type="scope.row.isReceive==1?'success':'danger'"  v-if="scope.row.isReceive==item.dictValue">{{item.dictLabel}}</el-tag>
          </template>
      </el-table-column>
     
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  fixed="right" width="120">
        <template slot-scope="scope">
          <el-button
           v-if="scope.row.isReceive==0&&scope.row.status==1"
            size="mini"
            type="text"
            @click="handleReceive(scope.row)"
            v-hasPermi="['crm:customer:receive']"
          >认领</el-button>
          <el-button
           v-if="scope.row.isReceive==1&&scope.row.status==1"
            size="mini"
            type="text"
            @click="handleRecover(scope.row)"
            v-hasPermi="['crm:customer:recover']"
          >回收</el-button>
          <el-button
           v-if="scope.row.isReceive==0&&scope.row.status==1"
            size="mini"
            type="text"
            @click="handleAssign(scope.row)"
            v-hasPermi="['crm:customer:assign']"
          >分配</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-log"
            @click="handleShow(scope.row)"
            v-hasPermi="['crm:customer:query']"
          >查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改客户对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="650px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
          <el-row>
             <el-col :span="12">
              <el-form-item label="客户编号" prop="customerCode">
                <el-input v-model="form.customerCode" maxlength="22" show-word-limit :disabled="title=='修改客户'"  placeholder="请输入客户编号" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="客户名称" prop="customerName">
                <el-input v-model="form.customerName" placeholder="请输入客户名称" />
              </el-form-item>
            </el-col>
           
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="客户类型" prop="customerType">
                <el-select v-model="form.customerType" placeholder="请选择客户类型" clearable size="small">
                  <el-option
                        v-for="dict in customerTypeOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="所属部门" prop="deptId">
                <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
              </el-form-item>
            </el-col>
           
          </el-row>
          <el-row>
          <el-col :span="12">
            <el-form-item label="行业类型" prop="industryType">
                <el-select v-model="form.industryType" placeholder="请选择行业类型" clearable size="small">
                  <el-option
                        v-for="dict in customerIndustryTypeOptions"
                        :key="dict.dictLabel"
                        :label="dict.dictLabel"
                        :value="dict.dictLabel"
                      />
                </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="总部客户" prop="isGeneral">
              <el-select v-model="form.isGeneral" placeholder="请选择总部客户" clearable size="small">
                  <el-option
                        v-for="dict in customerIsGeneralOptions"
                        :key="dict.dictLabel"
                        :label="dict.dictLabel"
                        :value="dict.dictLabel"
                      />
                </el-select>
            </el-form-item>
          </el-col>
        </el-row>
          <el-row>
             <el-col :span="12">
              <el-form-item label="手机" prop="mobile">
                <el-input v-model="form.mobile" placeholder="请输入手机" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="电话" prop="telephone">
                <el-input v-model="form.telephone" placeholder="请输入电话" />
              </el-form-item>
            </el-col>
            
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="网址" prop="website">
                <el-input v-model="form.website"   placeholder="请输入网址" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="邮箱" prop="email">
                <el-input v-model="form.email" placeholder="请输入邮箱" />
              </el-form-item>
            </el-col>
            
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="单位人数" prop="persons">
                <el-input type="number" v-model="form.persons" placeholder="请输入单位人数" />
              </el-form-item>
            </el-col>
             <el-col :span="12">
              <el-form-item label="详细地址" prop="detailAddress">
                <el-input v-model="form.detailAddress" placeholder="请输入详细地址" />
                <el-button type="text" @click="openMap">地图选择</el-button>
              </el-form-item>
            </el-col>
            
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="状态">
                <el-radio-group v-model="form.status">
                  <el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
                </el-radio-group>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="备注" prop="remark">
                <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
              </el-form-item>
            </el-col>
          </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
        <el-form  >
         <el-row>
            <el-col :span="24">
               <el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="upload.url + '?updateSupport=' + upload.updateSupport" :disabled="upload.isUploading" :on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" :auto-upload="false" drag>
                  <i class="el-icon-upload"></i>
                  <div class="el-upload__text">
                    将文件拖到此处，或
                    <em>点击上传</em>
                  </div>
                  <div class="el-upload__tip" slot="tip">
                    <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
                    <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
                  </div>
                  <div class="el-upload__tip" style="color:red" slot="tip">提示：仅允许导入“xls”或“xlsx”格式文件！</div>
                </el-upload> 
            </el-col>
        </el-row>
        </el-form>
    
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
    <el-dialog :title="map.title" :visible.sync="map.open" width="600px" append-to-body>
        <div style="margin-bottom:10px">
            <el-input v-model="form.detailAddress"  />
        </div>
        <div id="mymap" style="width:600px;height:500px;">
        </div>
    </el-dialog>
    <el-drawer
     size="50%"
     :with-header="false"
      :title="show.title" :visible.sync="show.open"
      >
        <customer  ref="customer" />
    </el-drawer>
     <el-dialog :title="assign.title" :visible.sync="assign.open" width="600px" append-to-body>
         <el-form ref="assignForm" :model="assignForm" :rules="assignRules" label-width="80px">
          <el-row>
            <el-col :span="24">
              <el-form-item label="客户名称" prop="customerName">
                <el-input v-model="assignForm.customerName" :disabled="true" placeholder="请输入客户名称" />
              </el-form-item>
            </el-col>
            
          </el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="分配员工" prop="receiveUserId" >
                    <el-select v-model="assignForm.receiveUserId"  placeholder="请选择员工">
                      <el-option
                        v-for="item in users"
                        :key="item.userId"
                        :label="item.nickName"
                        :value="item.userId">
                      </el-option>
                    </el-select>
                </el-form-item>
            </el-col>
            
          </el-row>

            
         </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitAssignForm">确 定</el-button>
          <el-button @click="assign.open = false">取 消</el-button>
        </div>
    </el-dialog>
  </div>
</template>

<script>
import { assign,recover,fullListCustomer,importTemplate,receive,getCustomer, delCustomer, addCustomer, updateCustomer, exportCustomer } from "@/api/crm/customer";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import customer from "../../components/customerDetails";
 import { getSelectUserList} from "@/api/system/user";


export default {
  name: "Customer",
  components: { Treeselect,customer },
  data() {
    return {
      users:[],
      assignForm:{
        customerName:undefined,
        customerId:undefined,
        receiveUserId:undefined,
      },
      assignRules: {
        receiveUserId: [
          { required: true, message: "请选择员工", trigger: "blur" },
        ]
      },
      assign:{
        open:false,
        title:'客户分配'
      },
      show:{
        open:false,
        title:'客户详情'
      },
      markersArray:[],
      map:{
        open:false,
        title:'地图选择'
      },
       // 导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        updateSupport: 0,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url: process.env.VUE_APP_BASE_API + "/crm/customer/importData",
      },
      customerTypeOptions:[],
      deptOptions:[],
      statusOptions:[],
      receiveOptions:[],
      customerIndustryTypeOptions:[],
      customerIsGeneralOptions:[],
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 客户表格数据
      customerList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        customerName: null,
        mobile: null,
        telephone: null,
        website: null,
        email: null,
        createUserId: null,
        address: null,
        location: null,
        detailAddress: null,
        lng: null,
        lat: null,
        status: null,
        isReceive: null,
        deptId: null,
        isDel: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
         customerCode: [
          { required: true, message: "客户编号不能为空", trigger: "blur" },
        ],
        customerType: [
          { required: true, message: "客户类型不能为空", trigger: "blur" },
        ],
        customerName: [
          { required: true, message: "客户姓名不能为空", trigger: "blur" },
        ],
        mobile: [
          { required: true, message: "手机号不能为空", trigger: "blur" },
        ],
        deptId: [
          { required: true, message: "所属部门不能为空", trigger: "blur" },
        ],
        customerName: [
          { required: true, message: "客户姓名不能为空", trigger: "blur" },
        ],
        customerName: [
          { required: true, message: "客户姓名不能为空", trigger: "blur" },
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        industryType: [
          { required: true, message: "行业类型不能为空", trigger: "blur" }
        ],
        
      }
    };
  },
  created() {
    this.getList();
    this.getDicts("customer_status").then((response) => {
      this.statusOptions = response.data;
    });
    this.getDicts("customer_receive").then((response) => {
      this.receiveOptions = response.data;
    });
    this.getDicts("customer_type").then((response) => {
      this.customerTypeOptions = response.data;
    });
     this.getDicts("customer_industry_type").then((response) => {
      this.customerIndustryTypeOptions = response.data;
    });
     this.getDicts("customer_is_general").then((response) => {
      this.customerIsGeneralOptions = response.data;
    });
    
    this.getTreeselect();
   
  },
  mounted() {
   
  },
  methods: {
      getSelectUserList() {
        getSelectUserList(null).then(response => {
          this.users = response.data;
        });
    },
    openCustomer(row){
      this.show.open=true;
      const customerId = row.customerId || this.ids
      setTimeout(() => {
        this.$refs.customer.getCustomerDetails(customerId);
      }, 500);
    },
    initMap () {
      var that = this;
      //https://lbs.qq.com/webApi/javascriptV2/jsGuide/jsEvent
    
      var myLatlng = new qq.maps.LatLng(36.046696, 103.859564);
      var myOptions = {
          zoom: 12,
          center: myLatlng
      };
      var map = new qq.maps.Map(document.getElementById("mymap"), myOptions);
      var listener = qq.maps.event.addListener(
          map,
          'click',
          function(event) {
              if (that.markersArray) {
                  for (var i in that.markersArray) {
                      that.markersArray[i].setMap(null);
                  }
                  that.markersArray.length = 0;
              }
              var marker = new qq.maps.Marker({
                  //设置Marker的位置坐标
                  position: event.latLng,
                  //设置显示Marker的地图
                  map: map
              });
              that.markersArray.push(marker);
              var lat = event.latLng.getLat().toFixed(6);
              var lng = event.latLng.getLng().toFixed(6); 
              that.form.lng=lng;
              that.form.lat=lat;
              var coord=new qq.maps.LatLng(lat,lng);
              geocoder.getAddress(coord);        
            
          }
      );
      var geocoder = new qq.maps.Geocoder({
          complete:function(result){
              console.log(result);
              that.form.detailAddress=result.detail.address.substr(2,result.detail.address.length-1);
          }
      });

    },
    openMap(){
      this.map.open=true;
      setTimeout(() => {
        this.initMap();
      }, 500);
      
    },
    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then((response) => {
        this.deptOptions = response.data;
      });
    },
    /** 查询客户列表 */
    getList() {
      this.loading = true;
      fullListCustomer(this.queryParams).then(response => {
        this.customerList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        customerId: null,
        customerName: null,
        mobile: null,
        telephone: null,
        website: null,
        email: null,
        remark: null,
        createUserId: null,
        address: null,
        location: null,
        detailAddress: null,
        lng: null,
        lat: null,
        createTime: null,
        updateTime: null,
        status: '0',
        isReceive: null,
        deptId: null,
        isDel: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.customerId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加客户";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const customerId = row.customerId || this.ids
      getCustomer(customerId).then(response => {
        this.form = response.data;
        this.form.status = response.data.status.toString();
        this.form.customerType = response.data.customerType.toString();
        this.form.industryType = response.data.industryType.toString();
        this.form.isGeneral = response.data.isGeneral.toString();
        this.open = true;
        this.title = "修改客户";
      });
    },
    handleShow(row) {
      this.show.open=true;
      const customerId = row.customerId || this.ids
      setTimeout(() => {
        this.$refs.customer.getCustomerDetails(customerId);
      }, 500);
      
    },
    handleReceive(row) {
        this.$confirm('是否确认认领客户"' + row.customerName + '"?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
           var data={customerId:row.customerId};
           return receive(data).then(response => {
              if (response.code === 200) {
              }
            });

        }).then(() => {
          this.getList();
          this.msgSuccess("认领成功");
        }).catch(function() {});
     
    },
    handleRecover(row) {
        this.$confirm('是否确认回收客户"' + row.customerName + '"?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
           var data={customerId:row.customerId};
           return recover(data).then(response => {
              if (response.code === 200) {
              }
            });

        }).then(() => {
          this.getList();
          this.msgSuccess("回收成功");
        }).catch(function() {});
     
    },
    handleAssign(row) {
      this.assign.open=true; 
      this.assignForm.customerName=row.customerName  
      this.assignForm.customerId=row.customerId   
      this.assignForm.receiveUserId=undefined;
       this.getSelectUserList();
     
    },
    submitAssignForm(){
      this.$refs["assignForm"].validate(valid => {
        if (valid) {
          assign(this.assignForm).then(response => {
              if (response.code === 200) {
                this.msgSuccess("分配成功");
                this.assign.open = false;
                this.getList();
              }
            });
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.customerId != null) {
            updateCustomer(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addCustomer(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const customerIds = row.customerId || this.ids;
      this.$confirm('是否确认删除客户编号为"' + customerIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delCustomer(customerIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有客户数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportCustomer(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "客户导入";
      this.upload.open = true;
    },
    /** 下载模板操作 */
    importTemplate() {
      importTemplate().then((response) => {
        this.download(response.msg);
      });
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
  }
};
</script>
<style>
 
</style>
